/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 28/08/2011, 07:28:07 AM
 */

package GUI;

import BE.Permisos;
import GUI.AdministracionPlantillas.*;
import java.awt.BorderLayout;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;

/**
 *
 * @author CarLita
 */
public class Principal extends javax.swing.JFrame {
    public static final int MODO_LECTURA = 1;
    public static final int MODO_EDICION = 2;
    public static final int MODO_CREACION = 3;
    public static final int MODO_LLENADO = 4;
    Inicio panelInicio;
    public PanelPlantillas panelPlantillas;
    public PanelProyectos panelProyectos;
    public PanelUsuarios panelUsuarios;    
    PanelBotonesProyectos panelBotonesProyectos;
    PanelBotonesPlantillas panelBotonesPlantillas;
    private Permisos permisos;
    /** Creates new form Principal */
    public Principal() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
        initComponents();
        inicializar();
    }

    Principal(Permisos permisos) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
        initComponents();
        this.permisos = permisos;
        inicializar();
    }

    public final void inicializar(){
        panelInicio = new Inicio(this);
        panelPlantillas = new PanelPlantillas(this);
        panelBotonesPlantillas = new PanelBotonesPlantillas();
        panelProyectos = new PanelProyectos(this);
        panelBotonesProyectos = new PanelBotonesProyectos();
        panelUsuarios = new PanelUsuarios(this);        
        panelContenedor.setLayout(new BorderLayout());
        mostrarInicio();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelContenedor = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        lblAyuda = new javax.swing.JLabel();
        lblSalir = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu6 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        panelContenedor.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout panelContenedorLayout = new javax.swing.GroupLayout(panelContenedor);
        panelContenedor.setLayout(panelContenedorLayout);
        panelContenedorLayout.setHorizontalGroup(
            panelContenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 812, Short.MAX_VALUE)
        );
        panelContenedorLayout.setVerticalGroup(
            panelContenedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 546, Short.MAX_VALUE)
        );

        jLabel1.setIcon(new javax.swing.ImageIcon("C:\\Users\\CarLita\\Desktop\\Tesis\\Iconos\\home.png")); // NOI18N
        jLabel1.setText("Inicio");
        jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        lblAyuda.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblAyuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/imagenes/gnome-help.png"))); // NOI18N
        lblAyuda.setText("Ayuda");
        lblAyuda.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        lblAyuda.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        lblSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/imagenes/exit.png"))); // NOI18N
        lblSalir.setText("Salir");
        lblSalir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        lblSalir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        lblSalir.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblSalirMouseClicked(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Space Age", 0, 48)); // NOI18N
        jLabel2.setText("DocCAAT");

        jMenu1.setText("Inicio");

        jMenuItem1.setText("Salir");
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Plantillas");

        jMenuItem6.setText("Crear Plantilla");
        jMenu2.add(jMenuItem6);

        jMenuItem7.setText("Buscar Plantilla");
        jMenu2.add(jMenuItem7);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Proyectos");

        jMenuItem8.setText("Crear Nuevo Proyecto");
        jMenu3.add(jMenuItem8);

        jMenuItem9.setText("Buscar Proyecto");
        jMenu3.add(jMenuItem9);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Reportes");

        jMenuItem5.setText("Generar reporte");
        jMenu4.add(jMenuItem5);

        jMenuBar1.add(jMenu4);

        jMenu5.setText("Auditoría");

        jMenuItem4.setText("Ver movimientos");
        jMenu5.add(jMenuItem4);

        jMenuBar1.add(jMenu5);

        jMenu6.setText("Ayuda");

        jMenuItem2.setText("Acerca de...");
        jMenu6.add(jMenuItem2);

        jMenuItem3.setText("Tutorial");
        jMenu6.add(jMenuItem3);

        jMenuBar1.add(jMenu6);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelContenedor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 267, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(47, 47, 47)
                .addComponent(lblAyuda)
                .addGap(51, 51, 51)
                .addComponent(lblSalir)
                .addGap(30, 30, 30))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap(20, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(lblAyuda)
                            .addComponent(lblSalir))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(panelContenedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    public void mostrarInicio(){
        panelContenedor.add(panelInicio, BorderLayout.NORTH);
        panelInicio.setVisible(true);
    }

    private void lblSalirMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSalirMouseClicked
        if (evt.getButton() == evt.BUTTON1){
            int salida = JOptionPane.showConfirmDialog(panelContenedor, "Desea salir del Doc. CAAT?", null, JOptionPane.YES_NO_OPTION);
            if (salida == JOptionPane.YES_OPTION)
                this.dispose();
            
        }
    }//GEN-LAST:event_lblSalirMouseClicked

    /**
    * @param args the command line arguments
    */

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);                
            }
        });
    }

    public JPanel getContenedor(){
        return panelContenedor;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JLabel lblAyuda;
    private javax.swing.JLabel lblSalir;
    public javax.swing.JPanel panelContenedor;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the permisos
     */
    public Permisos getPermisos() {
        return permisos;
    }

    /**
     * @param permisos the permisos to set
     */
    public void setPermisos(Permisos permisos) {
        this.permisos = permisos;
    }

}
